
const App = getApp()
/* var businessLogic = require('../../../utils/NetWork/Model/NewsbusinessLogic.js') */
var businessLogic = require('../../../utils/NetWork/Model/LoginbusinessLogic.js')
var WxParse = require('../../../utils/Component/wxParse/wxParse.js');
var common = require('../../../utils/common.js')
var orgid = common.getStorageSync("orgid")
var userid = common.getStorageSync("userid")

Page({
  data: {
    itemData2: [],
    orgid: "",
    userid: "",
    openid:""

  },
  add:function(){
    wx.navigateTo({
      url: "../../Login/boundwx/boundwx?tiaoid=1"
    });
  },
  touchS: function (e) {  // touchstart
    let startX = App.Touches.getClientX(e)
    startX && this.setData({ startX })
  },
  touchM: function (e) {  // touchmove
    let itemData2 = App.Touches.touchM(e, this.data.itemData2, this.data.startX)
    itemData2 && this.setData({ itemData2 })

  },
  touchE: function (e) {  // touchend
    const width = 150  // 定义操作列表宽度
    let itemData2 = App.Touches.touchE(e, this.data.itemData2, this.data.startX, width)
    itemData2 && this.setData({ itemData2 })
  },
  itemDelete2: function (e) {  // itemDelete
     let itemData2 = App.Touches.deleteItem(e, this.data.itemData2)
     let itemData=e.currentTarget.dataset.hi;
     var n = itemData.split("||||");
     console.log(n);
     for(let i = 0 ; i<n.length;i++){
       if (n[i] == this.data.openid){
         n.splice(i, 1);
       }
     }
     n = n.join('||||');
     console.log(n);
     let InfoJson = '{ "userid": "' + userid + '", "orgid": "' + orgid + '", "id": "' + userid + '", "openid": "' + n + '"}'
     let params2 = { "orgid": orgid, "userid": userid, "InfoJson": InfoJson }
     //     //第三步 调用接口
     businessLogic.bangding(params2, (res) => {
  
       common.showToast("取消成功", "succeed");
     
     });
     itemData2 && this.setData({ itemData2 })
   }, 

  /**
 * 生命周期函数--监听页面加载
 */

  onReady: function (options) {
    // this.list();
  },
  onLoad: function (options) {
    let c = common.Getorgid();
    this.setData({
      orgid: c.orgid,
      userid: c.userid,
      openid: c.openid
    });
    this.list();
  },
  onShow: function (options) {
    // this.list();
  },
  //2.1.1
  list: function (e) {

    let params = { "userid": this.data.userid, "orgid": this.data.orgid, "searchField": "openid", "searchValue": "" + this.data.openid + "" }
    //第三步 调用接口
    businessLogic.weixinhao(params, (res) => {
      console.log( res)
      //第五步 把获取的值，传入data
      this.setData({
        itemData2:res
      });


    });

  }, 


  // 跳转至详情页
  // addOrder: function (event) {
  //   wx.navigateTo({
  //     url: "../addOrder/addOrder"
  //   })

  // },
  // orderNewsli: function (event) {
  //   wx.navigateTo({
  //     url: "../orderNewsli/orderNewsli?id=" + event.currentTarget.dataset.id
  //   })
  // },
})